{include file='public:header-css'/}
<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        {include file='public:left-menu'/}
        <!--End 左侧导航-->
        <!--头部信息-->
        {include file='public:nav-header' title="系统管理" subTitle="全国地区"/}
        <!--End 头部信息-->
        <!--页面主要内容-->
        <main class="lyear-layout-content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="hint">
                                <div class="hint-info">
                                    <h5><i class="mdi mdi-help-circle-outline"></i>操作提示</h5>
                                    <p class="text-red">删除地区将会影响收货地址 运费模板等 请谨慎操作删除</p>
                                    <p>删除的地区如果有下级 则不允许删除</p>
                                </div>
                            </div>
                            <div class="card-toolbar">
                                <div class="toolbar-btn-action">
                                    <a class="btn btn-label btn-theme" href="{:url('System/add_edit_region')}"><label><i
                                            class="mdi mdi-checkbox-marked-circle-outline"></i></label> 添加地区</a>
                                </div>
                                <div class="card-toolbar-center">
                                    <a href="" class="table-btn btn-dark"><i class="mdi mdi-replay"></i></a>
                                    <button class="table-btn btn-theme">共{$list->total()}条记录
                                        当前第{$list->currentPage()}页
                                    </button>
                                </div>
                                <form class="table-form" method="post" action="">
                                    <div class="table-form-group">
                                        {if empty($id)}
                                        <select name="level" class="input-group-select">
                                            <option value="">选择地区</option>
                                            <option value="1" {if $Request.param.level=='1'}selected{/if}>省份</option>
                                            <option value="2" {if $Request.param.level=='2'}selected{/if}>城市</option>
                                            <option value="3" {if $Request.param.level=='3'}selected{/if}>区/县</option>
                                        </select>
                                        {/if}
                                        <input type="text" value="{$Request.param.keyword}" name="keyword"
                                               placeholder="查询地区名">
                                        <button class="btn btn-default" type="submit">搜索</button>
                                    </div>
                                </form>
                            </div>
                            <div class="card-body">
                                <table class="table table-bordered table-striped table-hover">
                                    <thead>
                                    <tr>
                                        <th style="width: 300px">操作</th>
                                        <th>ID</th>
                                        <th>地区</th>
                                        <th>上级地区</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {if $list->isEmpty()}
                                    <tr>
                                        <td class="no-data" colspan="50">
                                            <i class="mdi mdi-alert-decagram"></i>没有符合条件的记录
                                        </td>
                                    </tr>
                                    {else/}
                                    {volist name="$list" id="vo"}
                                    <tr>
                                        <td>
                                            {if $vo.level<3}
                                            <a class="table-btn btn-dark" href="{:url('System/region_index',['id'=>$vo[$vo.pk]])}"><i class="mdi mdi-eye"></i>查看下级</a>
                                            {/if}
                                            <a class="table-btn btn-theme" href="{:url('System/add_edit_region',['id'=>$vo[$vo.pk]])}"><i class="mdi mdi-pencil"></i>编辑</a>
                                            <a class="table-btn btn-danger" href="javascript:;" onclick="handel('{$vo[$vo.pk]}')"><i class="mdi mdi-delete"></i>删除</a>
                                        </td>
                                        <td>{$vo[$vo.pk]}</td>
                                        <td>{$vo.name}</td>
                                        <td>{$vo.parent_text}</td>
                                    </tr>
                                    {/volist}
                                    {/if}
                                    </tbody>
                                </table>
                                <!--分页-->
                                <div class="page">
                                    {$page|raw}
                                </div>
                            </div>
                        </div>
                    </div>

                </div>

            </div>

        </main>
        <!--End 页面主要内容-->
    </div>
</div>
<!--图片预览插件-->
<script type="text/javascript">
    $(function () {
    });
    function handel(id) {
        var text = "确认删除?";
        showConfirm(text, function () {
            var url = "{:url('System/region_delete')}";
            var data = {'ids': id};
            public_ajax(url, data, function (res) {
                if (res.code==1){
                    showSuccessMsg(res.msg,function () {
                        location.reload()
                    })
                }else {
                    showErrorMsg(res.msg);
                }
            })
        })
    }
</script>
</body>
</html>
